this.BX=this.BX||{};this.BX.Vue3=this.BX.Vue3||{};(function(t,e,i,s,o,n,r){"use strict";
/**
	 * Bitrix UI
	 * Reaction picker Vue component
	 *
	 * @package bitrix
	 * @subpackage ui
	 * @copyright 2001-2019 Bitrix
	 */const u="none";const a=Object.keys(n.reactionType);const l={...n.reactionCssClass,none:"ui-vue-reactions-icon-none"};const c=i.BitrixVue.mutableComponent("bx-reactions",{props:{name:{default:""},values:{default:{}},currentUserId:{default:0},canOpenList:{default:true}},data:()=>({localValues:{},userReaction:u,buttonAnimate:false}),emits:["list","set"],mounted(){this.userReactionAnimation=null;this.selectorPopup=null;this.selectorPopupHideTimeout=null;this.selectorPopupShowTimeout=null;this.localValues={...this.values};if(s.Type.isStringFilled(this.name)){this.$Bitrix.eventEmitter.subscribe(`ui:reaction:press:${this.name}`,this.onPress)}},beforeUnmount(){if(this.selectorPopup){this.selectorPopup.hide();this.selectorPopup=null}if(this.userReactionAnimation){this.userReactionAnimation.destroy()}clearTimeout(this.selectorPopupHideTimeout);this.selectorPopupHideTimeout=null;clearTimeout(this.selectorPopupShowTimeout);this.selectorPopupShowTimeout=null;if(s.Type.isStringFilled(this.name)){this.$Bitrix.eventEmitter.unsubscribe(`ui:reaction:press:${this.name}`,this.onPress)}},watch:{values:{handler(t){this.localValues={...t}},deep:true}},methods:{list(){if(!this.canOpenList){return false}this.$emit("list",{values:this.localValues});return true},set(t){if(!a.includes(t)){return false}if(this.localValues[this.userReaction]){this.localValues[this.userReaction]=this.localValues[this.userReaction].filter((t=>t!==this.currentUserId))}if(!this.localValues[t]){this.localValues={...this.localValues,[t]:[]}}this.localValues[t].push(this.currentUserId);this.buttonAnimate=true;setTimeout((()=>{this.buttonAnimate=false}),400);this.$emit("set",{action:"set",type:t});this.animateReactionButton(t);this.hideEmotionSelector(0);return true},unset(){if(this.userReaction===u){return true}if(this.localValues[this.userReaction]){this.localValues[this.userReaction]=this.localValues[this.userReaction].filter((t=>t!==this.currentUserId))}this.$emit("set",{action:"remove",type:this.userReaction});this.animateReactionButton(u);this.hideEmotionSelector(0);return true},press(t=n.reactionType.like){if(this.userReaction===u){return this.set(t)}this.unset()},showEmotionSelector(t){var e;if(this.selectorPopup){clearTimeout(this.selectorPopupHideTimeout);return false}const i=(e=this.name)!=null?e:Date.now();this.selectorPopup=new n.ReactionsSelect({name:i,position:t.target}).subscribe("select",(t=>{var e;const{reaction:i}=t.getData();this.set(i);(e=this.selectorPopup)==null?void 0:e.hide()})).subscribe("mouseleave",(()=>{this.hideEmotionSelector(500)})).subscribe("mouseenter",(()=>{clearTimeout(this.selectorPopupHideTimeout)})).subscribe("hide",(()=>{clearTimeout(this.selectorPopupHideTimeout);this.selectorPopup=null}));clearTimeout(this.selectorPopupShowTimeout);this.selectorPopupShowTimeout=setTimeout((()=>{var t;return(t=this.selectorPopup)==null?void 0:t.show()}),1e3)},hideEmotionSelector(t=1e3){clearTimeout(this.selectorPopupShowTimeout);clearTimeout(this.selectorPopupHideTimeout);if(!t){var e;(e=this.selectorPopup)==null?void 0:e.hide();return true}this.selectorPopupHideTimeout=setTimeout((()=>{var t;(t=this.selectorPopup)==null?void 0:t.hide()}),t)},onPress(t){const e=t.getData();if(!e.reaction){e.reaction=n.reactionType.like}this.press(e.reaction)},animateReactionButton(t){if(this.currentUserId<=0){return true}if(this.userReactionAnimation){this.userReactionAnimation.destroy()}if(t===u){return true}this.userReactionAnimation=r.Lottie.loadAnimation({animationData:n.ReactionsSelect.getLottieAnimation(t),container:this.$refs["reactions-button-icon"],loop:false,autoplay:false,renderer:"svg",rendererSettings:{viewBoxOnly:true}});this.userReactionAnimation.addEventListener("complete",(()=>{this.userReactionAnimation.destroy()}));this.userReactionAnimation.addEventListener("destroy",(()=>{this.userReactionAnimation=null}));this.userReactionAnimation.play();return true}},computed:{types(){this.userReaction=u;return a.filter((t=>{if(!s.Type.isArray(this.localValues[t])||this.localValues[t].length<=0){return false}if(this.currentUserId>0&&this.userReaction===u&&this.localValues[t].includes(this.currentUserId)){this.userReaction=t}return true})).map((t=>({type:t,count:this.localValues[t].length})))},counter(){return this.types.map((t=>t.count)).reduce(((t,e)=>t+e),0)},isTypesShowed(){if(this.counter<=0){return false}return!(this.userReaction!==u&&this.counter===1)},isMobile(){const t=navigator.userAgent.toLowerCase();return t.includes("android")||t.includes("iphone")||t.includes("ipad")||t.includes("bitrixmobile")},ReactionIconClass:()=>l},template:`\n\t\t<div :class="['ui-vue-reactions', {'ui-vue-reactions-mobile': isMobile}]">\n\t\t\t<transition name="ui-vue-reactions-result-animation">\n\t\t\t\t<div v-if="isTypesShowed" :class="['ui-vue-reactions-result', {'ui-vue-reactions-result-active': canOpenList}]" @click="list">\n\t\t\t\t\t<transition-group tag="div" class="ui-vue-reactions-result-types" name="ui-vue-reactions-result-type-animation" >\n\t\t\t\t\t\t<span v-for="element in types" :class="['ui-vue-reactions-result-type', ReactionIconClass[element.type]]" :key="element.type"></span>\n\t\t\t\t\t</transition-group>\t\n\t\t\t\t\t<div class="ui-vue-reactions-result-counter">{{counter}}</div>\n\t\t\t\t</div>\n\t\t\t</transition>\n\t\t\t<div v-if="currentUserId > 0"  class="ui-vue-reactions-button" @click.prevent="press()" @mouseenter="showEmotionSelector" @mouseleave="hideEmotionSelector()">\n\t\t\t\t<div class="ui-vue-reactions-button-container">\n\t\t\t\t\t<div :class="['ui-vue-reactions-button-icon', ReactionIconClass[userReaction], {'ui-vue-reactions-button-pressed': buttonAnimate}]" ref="reactions-button-icon"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t`});t.Reactions=c})(this.BX.Vue3.Components=this.BX.Vue3.Components||{},BX,BX.Vue3,BX,BX.Event,BX.Ui,BX.UI);
//# sourceMappingURL=reactions.bundle.map.js